package com.htc.android.footprints.kml;

import java.io.BufferedWriter;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.Iterator;

public class KMLDocument {
	public static final String KML_TIME_STAMP = "yyyy-MM-dd'T'hh:mm:ss'Z'";
	public String description = "This kml is created by HTC Footprints.";
	public String iconStyle;
	public String name = "My footprints";
	public ArrayList<KMLPlacemark> placemarksList;

	public String toString() {
		StringBuilder localStringBuilder1 = new StringBuilder();
		localStringBuilder1
				.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>").append(
						"\n");
		localStringBuilder1.append(
				"<kml xmlns=\"http://earth.google.com/kml/2.2\">").append("\n");
		localStringBuilder1.append("<Document>").append("\n");
		localStringBuilder1.append("<name>").append(this.name)
				.append("</name>").append("\n");
		StringBuilder localStringBuilder2 = localStringBuilder1
				.append("<description>");
		String str1;
		SimpleDateFormat localSimpleDateFormat;
		Iterator localIterator1;
		if (this.description == null) {
			str1 = "";
			localStringBuilder2.append(str1).append("</description>")
					.append("\n");
			localStringBuilder1.append("<Style id=\"icon_style\">")
					.append("<IconStyle>").append("<Icon>").append("<href>")
					.append(this.iconStyle).append("</href>").append("</Icon>")
					.append("</IconStyle>").append("</Style>").append("\n");
			localSimpleDateFormat = new SimpleDateFormat(
					"yyyy-MM-dd'T'hh:mm:ss'Z'");
			if (this.placemarksList != null)
				localIterator1 = this.placemarksList.iterator();
		} else {
			while (true) {
				if (!localIterator1.hasNext())
					break label731;
				KMLPlacemark localKMLPlacemark = (KMLPlacemark) localIterator1
						.next();
				localStringBuilder1.append("<Placemark>");
				localStringBuilder1.append("<name>")
						.append(localKMLPlacemark.name).append("</name>")
						.append("\n");
				localStringBuilder1.append("<TimeStamp> <when>");
				localStringBuilder1.append(localSimpleDateFormat
						.format(new Date(localKMLPlacemark.when)));
				localStringBuilder1.append("</when></TimeStamp>").append("\n");
				if ((localKMLPlacemark.address != null)
						&& (!localKMLPlacemark.address.equals("")))
					localStringBuilder1.append("<address>")
							.append(localKMLPlacemark.address)
							.append("</address>").append("\n");
				if ((localKMLPlacemark.phoneNumber != null)
						&& (!localKMLPlacemark.phoneNumber.equals("")))
					localStringBuilder1.append("<phoneNumber>")
							.append(localKMLPlacemark.phoneNumber)
							.append("</phoneNumber>").append("\n");
				if (!localKMLPlacemark.getDescription().equals(""))
					localStringBuilder1.append("<description>")
							.append(localKMLPlacemark.getDescription())
							.append("</description>").append("\n");
				StringBuilder localStringBuilder3 = localStringBuilder1
						.append("<styleUrl>");
				localKMLPlacemark.getClass();
				localStringBuilder3.append("#iconStyle").append("</styleUrl>")
						.append("\n");
				DecimalFormat localDecimalFormat = new DecimalFormat(
						"###.######");
				String str2 = localDecimalFormat
						.format(1.0E-006D * localKMLPlacemark.latitudeE6);
				String str3 = localDecimalFormat
						.format(1.0E-006D * localKMLPlacemark.longitudeE6);
				if ((localKMLPlacemark.latitudeE6 == 0)
						&& (localKMLPlacemark.longitudeE6 == 0))
					localStringBuilder1.append("<Point>")
							.append("<coordinates>").append("</coordinates>")
							.append("</Point>").append("\n");
				while (true) {
					localStringBuilder1.append("<ExtendedData>");
					Iterator localIterator2 = localKMLPlacemark.extendData
							.keySet().iterator();
					while (localIterator2.hasNext()) {
						String str4 = (String) localIterator2.next();
						localStringBuilder1.append("<Data name=\"" + str4
								+ "\">");
						localStringBuilder1.append("<value>")
								.append(localKMLPlacemark.getExtendData(str4))
								.append("</value>");
						localStringBuilder1.append("</Data>");
					}
					str1 = this.description;
					break;
					localStringBuilder1.append("<Point>")
							.append("<coordinates>").append(str3 + "," + str2)
							.append("</coordinates>").append("</Point>")
							.append("\n");
				}
				localStringBuilder1.append("</ExtendedData>").append("\n");
				localStringBuilder1.append("</Placemark>").append("\n");
			}
		}
		label731: localStringBuilder1.append("</Document>").append("\n");
		localStringBuilder1.append("</kml>").append("\n");
		return localStringBuilder1.toString();
	}

	public void writeTo(OutputStream paramOutputStream) {
		PrintWriter localPrintWriter = new PrintWriter(new BufferedWriter(
				new OutputStreamWriter(paramOutputStream)));
		localPrintWriter.write(toString());
		localPrintWriter.flush();
	}
}

/*
 * Location:
 * E:\workspace\dex2java\dex-translator-0.0.9.3\HtcFootprints_dex2jar.jar
 * Qualified Name: com.htc.android.footprints.kml.KMLDocument JD-Core Version:
 * 0.6.0
 */